<template>
  <div class="p-10">
    <h1 class="text-center p-12 text-5xl">{{ name }}</h1>
    <van-button type="danger" block @click="handleLogout">退出登录</van-button>
  </div>
</template>

<script setup lang="ts">
import { computed } from "vue";
import { useUser } from "../store/user";
import { useRouter } from "vue-router";
const user = useUser();
const router = useRouter(); //替代this.$router
let name = computed(() => {
  return user.userInfo ? user.userInfo.username : "尚未登录";
});
const handleLogout = () => {
  user.userInfo = null;
  router.push("/home");
};
</script>

<style scoped></style>
